#include "Logger.h"

Logger::Logger()
{
  m_sinkConsole = CreateRef<spdlog::sinks::stdout_color_sink_mt>();
  m_sinkConsole->set_level(spdlog::level::info);
  m_sinkConsole->set_pattern("%^[%T] %n: %v%$");

  m_sinkFile = CreateRef<spdlog::sinks::basic_file_sink_mt>("logs/Log.txt", true);
  m_sinkFile->set_level(spdlog::level::trace);
  m_sinkFile->set_pattern("[%T] [%l] %n: %v");

  logger = CreateScoped<spdlog::logger>(
      "Log", spdlog::sinks_init_list{m_sinkConsole, m_sinkFile});
  logger->set_level(spdlog::level::trace);
  logger->flush_on(spdlog::level::trace);
}


Logger &Logger::GetInstance()
{
  static Logger instance; // 静态局部变量，仅在第一次调用时初始化
  return instance;
}